#include <iostream>
#include "util.hpp"
#include "level.hpp"
#include "formatter.hpp"
#include "sink.hpp"

//using namespace LuLog;

int main() {
    // std::cout << LuLog::util::Date::now() << std::endl;
    // std::string path_name = "./abc/bcd/cde/a.txt";
    // LuLog::util::File::create_directory(LuLog::util::File::path(path_name));

    // LuLog::LogLevel::level value = LuLog::LogLevel::level::DEBUG;
    // std::cout << LuLog::LogLevel::toString(value) << std::endl;

    LuLog::LogMsg msg(LuLog::LogLevel::level::DEBUG, "r", "test.cc", 88, "test formatter");
    LuLog::Formatter fmt;
    std::string str = fmt.format(msg);
    //std::cout << str << std::endl;

    LuLog::LogSink::ptr stdoutPls = LuLog::SinkFactory::create<LuLog::StdoutSink>();
    LuLog::LogSink::ptr filePls = LuLog::SinkFactory::create<LuLog::FileSink>("./log/test.log");
    LuLog::LogSink::ptr rollPls = LuLog::SinkFactory::create<LuLog::RollSink>("./log/roll-", 1024*1024);
    stdoutPls->log(str.c_str(), str.size());
    for(int i = 0; i < 100; i++)
        filePls->log(str.c_str(), str.size());
    size_t curSize = 0;
    while(curSize <= 1024*1024*10){
        rollPls->log(str.c_str(), str.size());
        curSize += str.size();
    }

    return 0;
}
